<%@ page import="com.guotd.ticketSystem.entity.Cabin" %>
<%@ page import="java.util.List" %>
<%@page pageEncoding="UTF-8" contentType="text/html; UTF-8" isELIgnored="false" %>
<!doctype html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <meta name="viewport"
          content="width=device-width, user-scalable=no, initial-scale=1.0, maximum-scale=1.0, minimum-scale=1.0">
    <meta http-equiv="X-UA-Compatible" content="ie=edge">
    <title>客舱列表</title>
    <link rel="stylesheet" href="css/list.css">
</head>
<body>
<% List<Cabin> cabins = (List<Cabin>) request.getAttribute("cabins");
String flightId =request.getParameter("flightId");
%>
<%int type = (int) session.getAttribute("type"); %>
<%
    if (session.getAttribute("cabin_msg") != null)
    {
%>
<h2><%= session.getAttribute("cabin_msg") %></h2>
<%
    }
%>
<h1>当前航班：<%=flightId%></h1>
<% if (type==2)
{
%>
<a href="cabin_add.jsp?flightId=<%=flightId%>" class="table-button">添加客舱信息</a>
<a href="index_admin.jsp" class="table-button">回到主页</a>
<%
    }
%>
<% if (type==1)
{
%>
<a href="index_user.jsp" class="table-button">回到主页</a>
<%
    }
%>
<table>
    <tr>
        <th>名称</th>
        <th>美食</th>
        <th>服务</th>
        <th>手提行李</th>
        <th>免费托运行李</th>
        <th>价格</th>
        <th>余票</th>
        <th colspan="3">操作</th>
    </tr>
    <%
        if(cabins!=null){
            for (Cabin c : cabins) {
    %>
    <tr>
        <td> <%=c.getName()%> </td>
        <td> <%=c.getFood()%> </td>
        <td> <%=c.getService()%> </td>
        <td> <%=c.getHandBaggage()%> </td>
        <td> <%=c.getCheckedBaggage()%> </td>
        <td> <%=c.getPrice()%> </td>
        <td> <%=c.getCapacity()-c.getBooked()%> </td>
        <td> <a href="order_submit.jsp?cabinId=<%=c.getId()%>&&flightId=<%=flightId %>" class="table-button">预定</a> </td>
        <% if (type==2)
        {
        %>
        <td> <a href="delCabin?id=<%=c.getId()%>&&flightId=<%=flightId %>" class="table-button">删除</a> </td>
        <td> <a href="cabin_edit.jsp?id=<%=c.getId()%>&&name=<%=c.getName()%>&&food=<%=c.getFood()%>&&service=<%=c.getService()%>&&handBaggage=<%=c.getHandBaggage()%>&&checkedBaggage=<%=c.getCheckedBaggage()%>&&price=<%=c.getPrice()%>&&capacity=<%=c.getCapacity()%>&&booked=<%=c.getBooked()%>&&flightId=<%=flightId%>" class="table-button">编辑</a> </td>
    </tr>
    <%
        }
    %>
    <%
            }
        }
    %>
</table>
</body>
</html>